import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:ruida_bottom_demo/app/components/bottom3/bottom_bar_3.dart';

import '../controllers/bottom3_controller.dart';

class Bottom3View extends GetView<Bottom3Controller> {
  const Bottom3View({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('底部菜单 仿B站'),
        centerTitle: true,
      ),
      body: Stack(
        children: [content(), bottomBar()],
      ),
    );
  }

  Widget content() {
    return Positioned.fill(
        child: Container(
      alignment: Alignment.center,
      child: Obx(() {
        return Text(
          controller.pageIndex.value.toString(),
          style: TextStyle(color: Colors.grey[400], fontSize: 80),
        );
      }),
    ));
  }

  Widget bottomBar() {
    return Positioned(
      left: 0,
      right: 0,
      bottom: 0,
      child: BottomBar3(
        tabIconsList: controller.tabIconsList,
        changeIndex: (int index) {
          onClickBottomBar(index);
        },
        addClick: () {
          debugPrint('点击了中间的按钮');
        },
      ),
    );
  }

  void onClickBottomBar(int index) {
    controller.onClickBottomBar(index);
  }
}
